﻿using System;
using System.Collections.Generic;
using SinBiota.Model.Business.PersistenceServices.Interfaces;
using SinBiota.Model.Entities;
using SinBiota.Model.Persistence.Repositories.Interfaces;

namespace SinBiota.Model.Business.PersistenceServices.Implementation
{
    public class ConservationUnitPersistenceServices : IConservationUnitPersistenceServices
    {
        private readonly IConservationUnitRepository _conservationUnitRepository;

        public ConservationUnitPersistenceServices(IConservationUnitRepository conservationUnitRepository)
        {
            _conservationUnitRepository = conservationUnitRepository;
        }

        public ConservationUnit FindById(int id)
        {
            return _conservationUnitRepository.FindById(id);
        }

        public ConservationUnit FindByName(string name)
        {
            return _conservationUnitRepository.FindOneByExactName(name);
        }

        public IList<ConservationUnit> FindByNameLike(string name)
        {
            return _conservationUnitRepository.FindByNameLike(name);
        }

        public IList<ConservationUnit> FindAll()
        {
            return _conservationUnitRepository.FindAll();
        }

        public void Delete(ConservationUnit conservationUnit)
        {
            _conservationUnitRepository.Delete(conservationUnit);
        }

        public void DeleteById(int id)
        {
            Delete(FindById(id));
        }
        public void Save(ConservationUnit conservationUnit)
        {
            _conservationUnitRepository.Save(conservationUnit);
        }

        public void Update(ConservationUnit conservationUnit)
        {
            _conservationUnitRepository.Update(conservationUnit);
        }
    }
}